const mysql = require('mysql')
const pool = mysql.createPool({
    host: "localhost", //域名
   user: "root", //用户名
   password: "123456", //密码
   database: "node-admin", // 数据库名
   port: 3306, //端口号，默认是3000
})
function exec(sql) {
    return new Promise((resolve, reject) => {
        pool.query(sql, (err, data) => {
            if (err) {
                reject(err);
            } else {
                resolve(data);
            }
        })
    })
}
module.exports = {exec}